package com.clp.protocol.core.client;

import lombok.Getter;

import java.util.Objects;

/**
 * 客户端关闭 事件
 */
@Getter
public class ClientCloseEvent<C> extends ClientEvent<C> {
    protected Type type; // 事件类型

    public ClientCloseEvent(C source, Type type) {
        this(source, null, type);
    }

    public ClientCloseEvent(C source, Throwable cause, Type type) {
        super(source);
        Objects.requireNonNull(type, "Client event type can not be null!");
        this.type = type;
    }

    /**
     * 该事件类型
     */
    public enum Type {
        /**
         * 关闭前
         */
        CLOSE_BEFORE(),

        /**
         * 关闭成功后
         */
        CLOSE_SUCCESS(),

        /**
         * 关闭失败后
         */
        CLOSE_FAILED();
    }
}
